﻿using Mockery.Core;
using NUnit.Framework;
using Rhino.Mocks;

namespace Mockery.UnitTest
{
    [TestFixture]
    public class RepositoryStateHandlerTests
    {
        [Test]
        public void RepositoryStateHandler_ValidateArrangeStateChangeTest()
        {
            var mocks = new MockRepository();
            
            var mockeryStateEvents = mocks.StrictMock<IMockeryStateEvents>();

            mocks.Record();

            Expect.Call(() => mockeryStateEvents.OnFirstArrange());

            mocks.ReplayAll();

            var handler = new RepositoryStateHandler(mockeryStateEvents);

            handler.SetState(MockeryState.Arrange);

            mocks.VerifyAll();
        }

        [Test]
        public void RepositoryStateHandler_ValidateActStateChangeTest()
        {
            var mocks = new MockRepository();

            var mockeryStateEvents = mocks.StrictMock<IMockeryStateEvents>();

            mocks.Record();

            Expect.Call(() => mockeryStateEvents.OnFirstAct());

            mocks.ReplayAll();

            var handler = new RepositoryStateHandler(mockeryStateEvents);

            handler.SetState(MockeryState.Act);

            mocks.VerifyAll();
        }

        [Test]
        public void RepositoryStateHandler_ValidateAssertStateChangeTest()
        {
            var mocks = new MockRepository();

            var mockeryStateEvents = mocks.StrictMock<IMockeryStateEvents>();

            mocks.Record();

            Expect.Call(() => mockeryStateEvents.OnFirstAssert());

            mocks.ReplayAll();

            var handler = new RepositoryStateHandler(mockeryStateEvents);

            handler.SetState(MockeryState.Assert);

            mocks.VerifyAll();
        }

    }
}
